#include <iostream>

using namespace std;

int atoi1(const char *str)
{
	bool isNegative = false;
	int res = 0;
	char *pointer = (char *)str;
	if (str[0] == '-'){
		isNegative = true;
		pointer++;
	}
	do {
		if (*pointer >= '0' && *pointer <= '9')
			res = 10 * res + (*pointer - '0');
		else
			break;
		/* test overflow here!!! */
		pointer++;
	} while (*pointer);

	if (isNegative)
		res = -res;
	return res;
}

int atoi2(char *str)
{
	bool isNegative = false;
	char *pointer = NULL;
	return 0;
}

int atoiTest()
{
	char *test = "001";
	cout <<atoi1(test) <<endl;
	cin.get();
	return 0;
}